<html>
<head><meta charset="utf-8"><title>lecture on LLVM/codegen · t-compiler/wg-rustc-dev-guide · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/index.html">t-compiler/wg-rustc-dev-guide</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html">lecture on LLVM/codegen</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="181960656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960656">(Nov 26 2019 at 20:32)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="123586">@nagisa</span></p>



<a name="181960674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960674">(Nov 26 2019 at 20:32)</a>:</h4>
<p>Hi.</p>



<a name="181960690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960690">(Nov 26 2019 at 20:32)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1380">@WG-learning</span> was hoping you could do a lecture about LLVM/codegen so we could add it to the rustc-guide</p>



<a name="181960715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960715">(Nov 26 2019 at 20:33)</a>:</h4>
<p>It is one of the biggest long-standing gaps in the guide</p>



<a name="181960752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960752">(Nov 26 2019 at 20:33)</a>:</h4>
<p>Alternately, we could do some sort of discussion here on zulip if you prefer that</p>



<a name="181960771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960771">(Nov 26 2019 at 20:33)</a>:</h4>
<p>like we did with macros/hygiene with petrochenkov:</p>



<a name="181960773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960773">(Nov 26 2019 at 20:33)</a>:</h4>
<p>I don’t have the means to record a lecture, sadly.</p>



<a name="181960841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960841">(Nov 26 2019 at 20:34)</a>:</h4>
<p><a href="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/macros.20discussion" title="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/macros.20discussion">https://rust-lang.zulipchat.com/#narrow/stream/196385-t-compiler.2Fwg-learning/topic/macros.20discussion</a></p>



<a name="181960861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960861">(Nov 26 2019 at 20:34)</a>:</h4>
<p>Also LLVM and MIR→LLVM-IR codegen are two very distinct things and would deserve their separate two lectures.</p>



<a name="181960882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960882">(Nov 26 2019 at 20:34)</a>:</h4>
<p>Hmm</p>



<a name="181960888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960888">(Nov 26 2019 at 20:35)</a>:</h4>
<p>that's good to know</p>



<a name="181960920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960920">(Nov 26 2019 at 20:35)</a>:</h4>
<p>Would you be able to do something like the macros discussion here on zulip? (like the link above)</p>



<a name="181960921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960921">(Nov 26 2019 at 20:35)</a>:</h4>
<p>?</p>



<a name="181960997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181960997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181960997">(Nov 26 2019 at 20:36)</a>:</h4>
<p>We also understand if you are not able to</p>



<a name="181961079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181961079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181961079">(Nov 26 2019 at 20:37)</a>:</h4>
<p>I can write down some broad outline and point out where to look for more specifics. But also, again, codegen is very deceptively prone to look small. Do you have lectures on backend (linking, etc.)?</p>



<a name="181961108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181961108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181961108">(Nov 26 2019 at 20:38)</a>:</h4>
<p>That would be an excellent start!</p>



<a name="181961146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181961146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181961146">(Nov 26 2019 at 20:38)</a>:</h4>
<p>Unfortunately, we have nothing past the MIR opt</p>



<a name="181961170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181961170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181961170">(Nov 26 2019 at 20:38)</a>:</h4>
<p>nothing on monomorphization, LLVM IR generation, and very little on LLVM itself</p>



<a name="181961648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181961648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181961648">(Nov 26 2019 at 20:44)</a>:</h4>
<p>I have to go now. We would appreciate any information you can along in whatever format is most convenient for you. Please feel free to DM me</p>



<a name="181962513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/181962513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#181962513">(Nov 26 2019 at 20:50)</a>:</h4>
<p>Not gonna get anything earlier than some weekend.</p>



<a name="182018055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182018055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182018055">(Nov 27 2019 at 13:23)</a>:</h4>
<p>I've been talking with <span class="user-mention" data-user-id="116015">@Alex Crichton</span> (can do some LLVM) and <span class="user-mention" data-user-id="124288">@oli</span> who can do some of monomorphization and type layout</p>



<a name="182018083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182018083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182018083">(Nov 27 2019 at 13:23)</a>:</h4>
<p>could be good to coordinate, what would you cover <span class="user-mention" data-user-id="123586">@nagisa</span> ?</p>



<a name="182018207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182018207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182018207">(Nov 27 2019 at 13:25)</a>:</h4>
<p>also, <span class="user-mention" data-user-id="124287">@mw</span> do you have time and can cover some part?</p>



<a name="182018419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182018419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182018419">(Nov 27 2019 at 13:27)</a>:</h4>
<p>there's also <a href="https://github.com/rust-lang/rust/pull/54012" target="_blank" title="https://github.com/rust-lang/rust/pull/54012">https://github.com/rust-lang/rust/pull/54012</a> some people from there may know and be able to do something</p>



<a name="182256635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182256635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182256635">(Nov 30 2019 at 21:38)</a>:</h4>
<p>So, first, where do I see what we already have? I was planning to make a list of things that we should probably split into separate categories first.</p>



<a name="182256650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182256650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182256650">(Nov 30 2019 at 21:39)</a>:</h4>
<p>starting with "monomorpization collector" and ending with "backend/linker invocation/lto".</p>



<a name="182256671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182256671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182256671">(Nov 30 2019 at 21:39)</a>:</h4>
<p>There are few things I <em>cannot</em> cover in there, collector being one of those things.</p>



<a name="182257126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182257126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182257126">(Nov 30 2019 at 21:48)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> Thanks!<br>
This is all we have: <a href="https://rust-lang.github.io/rustc-guide/codegen.html" target="_blank" title="https://rust-lang.github.io/rustc-guide/codegen.html">https://rust-lang.github.io/rustc-guide/codegen.html</a><br>
so any info you have would be wonderful</p>



<a name="182257139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182257139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182257139">(Nov 30 2019 at 21:48)</a>:</h4>
<p>I guess we should create a placeholder chapter for each of the categories you come up with</p>



<a name="182286060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182286060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182286060">(Dec 01 2019 at 13:58)</a>:</h4>
<p><a href="https://gist.github.com/nagisa/a311a0dab09851397f266076130eefb6" target="_blank" title="https://gist.github.com/nagisa/a311a0dab09851397f266076130eefb6">https://gist.github.com/nagisa/a311a0dab09851397f266076130eefb6</a> some braindumping</p>



<a name="182672435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182672435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182672435">(Dec 05 2019 at 15:51)</a>:</h4>
<p>Hi!</p>
<p>I had a thread where I was pretty much asking about the same kind of lecture:<br>
<a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Lecture.20Series.20Suggesion.3A.20Monomorphisation" title="#narrow/stream/182449-t-compiler.2Fhelp/topic/Lecture.20Series.20Suggesion.3A.20Monomorphisation">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Lecture.20Series.20Suggesion.3A.20Monomorphisation</a></p>
<p>I think it'd be good to explain why monomorphisation occurs in the codegen, and not at the MIR level. This surprised me.</p>
<p>Thanks</p>



<a name="182673047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182673047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182673047">(Dec 05 2019 at 15:56)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="123586">@nagisa</span></p>



<a name="182675827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182675827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182675827">(Dec 05 2019 at 16:23)</a>:</h4>
<p>relevant: <a href="https://github.com/rust-lang/rust/issues/66969" target="_blank" title="https://github.com/rust-lang/rust/issues/66969">https://github.com/rust-lang/rust/issues/66969</a></p>



<a name="182681404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182681404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182681404">(Dec 05 2019 at 17:17)</a>:</h4>
<p><span class="user-mention" data-user-id="223288">@Edd Barrett</span> My understanding is that it sort of does happen at the MIR level. But first, we have to find out what to codegen (i.e. how do you codegen a <code>Vec&lt;T&gt;</code> without first knowing what <code>T</code> is?). So after the MIR is produced/checked/optimized, we monomorphize, then we generate code for the monomorphized versions.</p>



<a name="182681613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182681613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182681613">(Dec 05 2019 at 17:19)</a>:</h4>
<p><span class="user-mention" data-user-id="198054">@mark-i-m</span> But you don't generate a new MIR body for each monomorphisation, do you?</p>



<a name="182683968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182683968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182683968">(Dec 05 2019 at 17:43)</a>:</h4>
<p>Not sure, but I don't think so. My understanding is that we only collect a list of concrete instantiations of each generic MIR body. We then iterate through the list and generate code with that concrete instance. Not 100% sure though</p>



<a name="182684044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182684044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182684044">(Dec 05 2019 at 17:44)</a>:</h4>
<p>That's in line with my understanding.</p>



<a name="182686538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182686538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182686538">(Dec 05 2019 at 18:12)</a>:</h4>
<p>We figure out the necessary concrete instantiations as part of collector and codegen unit distribution (occurs right before we lower MIR into LLVM) and then for each such instantiation we run a separate lowering pass. Lowering then monomorphises various generic statements etc. within MIR as it goes.</p>



<a name="182687063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182687063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182687063">(Dec 05 2019 at 18:17)</a>:</h4>
<p>So yes, the descriptions above seem fairly on-point <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="182687227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/182687227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#182687227">(Dec 05 2019 at 18:19)</a>:</h4>
<p>Perhaps it is also good to mention why this decision has been made, because it is a tradeoff – we anticipate MIR to be optimised as far as it being generic allows first, so that we end up spending less time on lowering monomorphic forms and reducing the workload LLVM has to handle. That being said there’s nothing preventing us from having what <span class="user-mention" data-user-id="119009">@eddyb</span> calls LIR which is essentially MIR but monomorphic.</p>



<a name="183060352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/183060352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#183060352">(Dec 10 2019 at 13:48)</a>:</h4>
<p>Turns out the collector has some nice documentation <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/collector/index.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/collector/index.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/collector/index.html</a> already</p>



<a name="183064146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture%20on%20LLVM/codegen/near/183064146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/lecture.20on.20LLVM.2Fcodegen.html#183064146">(Dec 10 2019 at 14:31)</a>:</h4>
<p>It might also be useful to state the difference between "declaring" and "defining".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>